home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / vol6n17.arc / QP-TURBO.ASM < prev    next >
Assembly Source File  |  1987-09-09  |  4KB  |  79 lines

  1. ;QPRINT.ASM - performs Quick Printing with Turbo Basic
  2. ;Note: Assemble this with MASM (2.0 or later), then LINK, convert
  3. ;      to a binary file with EXE2BIN, and finally rename as QPrint.Com
  4. ;Copyright 1987, Ziff Communications Co.
  5.  
  6. Code        Segment Byte
  7.             Assume  CS:Code
  8.  
  9. QPrint      Proc    Far
  10.  
  11. Begin:      Push  BP            ;save registers for BASIC
  12.             Push  DS
  13.  
  14.             Mov   AH,3          ;specify BIOS service to read cursor position
  15.             Mov   BH,0          ;on text page zero
  16.             Int   10h           ;this service returns row/column in DH/DL
  17.  
  18.             Mov   AL,DH         ;put the current row number into AL
  19.             Mov   CL,160        ;multiply by 160 to get start address of row
  20.             Mul   CL            ;do the multiplication, answer ends up in AX
  21.             Mov   DH,0          ;clear DH for the Add below, we only want DL
  22.             Add   AX,DX         ;add the column once for the character byte
  23.             Add   AX,DX         ;and once more for the attribute byte
  24.             Mov   DI,AX         ;now DI holds starting address on the screen
  25.  
  26.             Xor   DX,DX         ;zero out DX to look at low memory using ES
  27.             Mov   ES,DX
  28.             Mov   BX,0B000h     ;assume the mono screen segment for now
  29.             Mov   AL,ES:[463h]  ;look at the video controller port address
  30.             Cmp   AL,0B4h       ;is it mono?
  31.             JZ    Get_Params    ;yes, skip over adding 800h to video segment
  32.             Add   BX,800h       ;no, adjust BX for a color monitor
  33.             Push  BX            ;and save it because the EGA test destroys BX
  34.  
  35.             Mov   AH,12h        ;specify EGA BIOS EGA special function service
  36.             Mov   BL,10h        ;request EGA info
  37.             Int   10h           ;call the BIOS
  38.             Cmp   BL,10h        ;if BL is still 10h, there's no EGA
  39.             JNZ   EGA           ;it is an EGA, skip ahead
  40.             Mov   DX,3DAh       ;not EGA, specify port to check for retrace
  41.  
  42. EGA:        Pop   BX            ;get the video segment again
  43.  
  44. Get_Params: Mov   BP,SP         ;get stack pointer so we can find variables
  45.             Mov   ES,BX         ;move whatever segment is correct into ES
  46.             LDS   SI,[BP+08]    ;get the color that was passed
  47.             Mov   AH,[SI]       ;and put it into AH for screen writing below
  48.             LDS   SI,[BP+12]    ;put descriptor to X$ into SI
  49.             Mov   CX,[SI]       ;put Len(X$) into CX for loop counter
  50.             And   CX,7FFFh      ;clear the length hi-bit
  51.             Mov   SI,[SI+02]    ;put address of first character in X$ into SI
  52.             JCXZ  Exit          ;if CX is zero it's a null string, exit now
  53.             Pop   DS            ;get DS back to find the string data segment
  54.             Push  DS            ;save it again
  55.             Mov   DS,DS:[0000]  ;the data segment is located at DS:[0000]
  56.             Cld                 ;clear the direction flag to move data forward
  57.  
  58. Check_Mon:  Cmp   DL,0          ;are we on a mono or EGA system?
  59.             JZ    Mono          ;yes, skip over the retrace stuff
  60.  
  61. No_Retrace: In    AL,DX         ;get the video status byte from port number DX
  62.             Test  AL,1          ;test just the horizontal retrace bit
  63.             JNZ   No_Retrace    ;if doing a retrace, wait until it's not
  64.  
  65. Retrace:    In    AL,DX         ;get the status byte again
  66.             Test  AL,1          ;are we doing a retrace now?
  67.             JZ    Retrace       ;no, wait until we are
  68.  
  69. Mono:       Lodsb               ;get the character from X$ and increment SI
  70.             Stosw               ;store both the character and attribute
  71.             Loop  Check_Mon     ;loop until CX is zero
  72.  
  73. Exit:       Pop   DS            ;restore the registers for BASIC
  74.             Pop   BP
  75.  
  76. QPrint      Endp
  77. Code        Ends
  78.             End   Begin
  79.